package com._58city.spark.app.ext.dao;

import javax.sql.DataSource;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;

/**
 * @author lihao
 * Dao的基础类，提取了一些通用属性
 */
@SuppressWarnings("deprecation")
public class BaseDao implements InitializingBean{
	
	protected String tableName; //表名
	
	protected DataSource dataSource; //数据源
		
	protected SimpleJdbcTemplate jdbcTemplate;
	
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}

	public void afterPropertiesSet() throws Exception {
		jdbcTemplate = new SimpleJdbcTemplate(dataSource);
	}
	
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	
	protected <V> Object[] params(V... a){
		Object[] params = new Object[a.length];
		for(int i = 0;i<a.length;i++) params[i] = a[i];
		return params;
	}

}
